<script type="text/javascript">
{literal}
	$(document).ready(function() {
		$('#usernameBox').focus();
		//add support select language
		$('#language_m').change(function () {
			window.location.href="SelectLanguage?lang=" + $(this).val() + '&ac=' + window.location.href;			
		});
		//end
		
	});

	function isReadyToSubmit() {
		$('#errorMsg').text('').hide();
		
		if( $('#department :selected').val() == '' ) {
			{/literal}
			$('#errorMsg').text('{translate}Please select a department{/translate}.').show();
			{literal}
			return false;
			
		}

		return true;	
	}
{/literal}	
</script>

<form name="login" method="post" action="{$TOP_ACTION}">
	
	<div class='login_top' style='text-align: left'>
		<div class='login_bottom' style='height: 200px;'>
			<div id='loginContainer'>
				<span id="errorMsg" style="color: red; display: none; margin-left: 30px;">&nbsp;</span>
		
				<div>
					<div  style='margin-bottom: 0px;'>
						{if $error}
							{$error}
						{/if}
					</div>
					<div style='margin-left: 40px;'>
						<label for='language_m'>{translate}Language{/translate}</label>
						<select name="language" id='language_m' selected='{$chosenLanguage}' style='width: 202px'>
							{html_options options=$languageList selected=$chosenLanguage}
						</select>
					</div>
					<div style='margin-left: 40px;'>
						<label for='usernameBox'>{translate}Username{/translate}&nbsp;</label>
						<input type="text" name="username" style='width: 200px' value="{$username}" id="usernameBox">
					</div>
					<div style='margin-left: 40px;'>
						<label for='passwordBox'>{translate}Password{/translate}&nbsp;</label>
						<input type="password" name="password" style='width: 200px' id='passwordBox'>
					</div>
					<div style='margin-left: 40px;'>
						<label for='department'>{translate}Department{/translate}&nbsp;</label>
						<select name="department" id='department' style='width: 202px'>
							<option value=''>--- {translate}Select department{/translate} ---</option>
							{html_options options=$departmentList selected=$defaultDepartment}
						</select>
					</div>
					<div style='text-align: center; margin-top: 20px;'>
						<button type="submit" name="submit" onclick="return isReadyToSubmit();">{translate}Login{/translate}</button>
					</div>
				</div>
	
	
				<input type="hidden" name="process" value="{$PROCESS}">
			</div>
		</div>
	</div>
</form>